﻿package mortal.game.view.doubleHang
{
    import Message.Public.*;
    import extend.language.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.manager.msgTip.*;
    import mortal.game.mvc.*;
    import mortal.mvc.core.*;

    public class DoubleHangeController extends Controller
    {

        public function DoubleHangeController()
        {
            return;
        }// end function

        override protected function initServer() : void
        {
            Dispatcher.addEventListener(EventName.ActiveStart, this.activesStartHandler);
            Dispatcher.addEventListener(EventName.ActiveEnd, this.activesEndHandler);
            Dispatcher.addEventListener(EventName.ActiveNotic, this.activesNoticHandler);
            Dispatcher.addEventListener(EventName.DoubleHangWindowShow, this.doubleHangWindowShowHandler);
            return;
        }// end function

        private function activesStartHandler(event:DataEvent) : void
        {
            var _loc_2:* = event.data as SClientActive;
            if (_loc_2.type == EActiveType._EActiveTypeDoubleHang)
            {
                if (cache.role.entityInfo.level >= 50)
                {
                    DoubleHangIcon.instance.show();
                    DoubleHangIcon.instance.playEffect();
                    DoubleHangIcon.instance.setLeftTimeAndState((_loc_2.endDt.time - ClockManager.instance.nowDate.time) * 0.001, 2);
                }
                else if (DoubleHangIcon.isViewShow)
                {
                    DoubleHangIcon.instance.hide();
                }
            }
            return;
        }// end function

        private function activesEndHandler(event:DataEvent) : void
        {
            var _loc_2:* = event.data as SClientActive;
            if (_loc_2.type == EActiveType._EActiveTypeDoubleHang)
            {
                if (DoubleHangIcon.isViewShow)
                {
                    DoubleHangIcon.instance.hide();
                }
            }
            return;
        }// end function

        private function activesNoticHandler(event:DataEvent) : void
        {
            var _loc_2:* = event.data as SClientActive;
            if (_loc_2.type == EActiveType._EActiveTypeDoubleHang)
            {
                if (Cache.instance.role.entityInfo.level >= 50)
                {
                    DoubleHangIcon.instance.show();
                    DoubleHangIcon.instance.setLeftTimeAndState((_loc_2.startDt.time - ClockManager.instance.nowDate.time) * 0.001, 1);
                }
                else if (DoubleHangIcon.isViewShow)
                {
                    DoubleHangIcon.instance.hide();
                }
            }
            return;
        }// end function

        private function doubleHangWindowShowHandler(event:DataEvent) : void
        {
            if (Cache.instance.role.entityInfo.level < 50)
            {
                MsgManager.showRollTipsMsg(Language.getString(11701), MsgRollTipsType.msgRollTips3);
            }
            else
            {
                DoubleHangWindow.instance.show();
            }
            return;
        }// end function

    }
}
